﻿<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <title>报表中心</title>
    <link rel='Shortcut Icon' type='image/x-icon' href='./img/windows.ico'>
    <script type="text/javascript" src="./js/jquery-2.2.4.min.js"></script>
    <link href="./css/animate.css" rel="stylesheet">
    <script type="text/javascript" src="./component/layer-v3.0.3/layer/layer.js"></script>
    <link rel="stylesheet" href="./component/font-awesome-4.7.0/css/font-awesome.min.css">
    <link href="./css/default.css" rel="stylesheet">
    <script type="text/javascript" src="./js/win10.js?v=1"></script>
    <script src="../assets/js/m.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <!--<script src="//cdn.bootcss.com/eruda/1.4.2/eruda.min.js"></script>
    <script>eruda.init();</script>-->
    <style>

        * {
            font-family: "Microsoft YaHei", 微软雅黑, "MicrosoftJhengHei", 华文细黑, STHeiti, MingLiu
        }
        /*磁贴自定义样式*/
        .win10-block-content-text {
            line-height: 44px;
            text-align: center;
            font-size: 16px;
        }

        .layui-layer-title {
            padding-left: 10px;
            font-weight: bold;
        }
    </style>
    <script>
        Win10.onReady(function () {

            //设置壁纸
            Win10.setBgUrl({
                main: './img/wallpapers/main.jpg',
                mobile: './img/wallpapers/mobile-nome.jpg',
            });

            Win10.setAnimated([
                'animated flip',
                'animated bounceIn',
            ], 0.01);
        });

    </script>

    <script>
        $(function () {

            //console.log("url=" + window.location.href);

            //获取地址栏参数
            function getUrlParam(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            }
            new window.Kmer({
                "AppRootPath": "",
                "CurrentUrl": ""
            });

            var code = getUrlParam("code");
            var config = getUrlParam("state");
            //layer.alert(code);
            Y.API2("WxReport", "GetDepartmentByCode",
                {
                    "Code": code, "wxConfig": config
                },
                function (data) {
                    console.log(data);
                    //layer.alert(reportList.length);
                    if (data.Success == false) {
                        console.log(data.Message);
                    } else {
                        var reportList = data;
                        var html = "";
                        for (var i = 0; i < reportList.length; i++) {
                            var report = reportList[i];
                            html +=
                                '<div id="desktopShortcut" class="shortcut desktopShortcut' + report.Id + '" data-url="' + report.Link+"&UserID="+report.UserId + '" data-title="' + report.Title + '" data-icon="./img/icon/win10.png">' +
                                '<img class="icon" src="./img/icon/win10.png" />' +
                                '<div class="title">' + report.Title + '</div>' +
                                '</div>';
                        }
                        $("#win10-shortcuts").html($("#win10-shortcuts").html() + html);
                        Win10.renderShortcuts();
                        //layer.alert(html);


                        var reportid = getUrlParam("reportid");
                        //console.log(reportid);
                        $('.desktopShortcut' + reportid).click();
                    }
                });

            var url3 = window.location.href;
            Y.API2("WXBase",
                "GetConfig", { "url": url3, "wxConfig": config },
                function (data) {

                    if (data.Success == false) {
                        console.log(data.Message);
                    } else {
                        wx.config({
                            //beta: true,// 必须这么写，否则wx.invoke调用形式的jsapi会有问题
                            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                            appId: data.corpId, // 必填，企业微信的corpID
                            timestamp: data.timeStamp, // 必填，生成签名的时间戳
                            nonceStr: data.nonceStr, // 必填，生成签名的随机串
                            signature: data.signature,// 必填，签名，见附录1
                            jsApiList: [
                                "onMenuShareWechat", "onMenuShareAppMessage", "hideOptionMenu"
                            ]
                            // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
                        });
                    }
                });

            wx.ready(function () {
                // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
                //分享给朋友接口
                //wx.onMenuShareAppMessage({
                //    title: 'xxx',
                //    desc: 'xxx',
                //    link: document.URL,
                //    imgUrl: '../images/02.png',
                //    success: function () { },
                //    cancel: function () { }
                //});
                /* begin禁用微信分享功能 */
                function onBridgeReady() {
                    WeixinJSBridge.call('hideOptionMenu');
                }

                if (typeof WeixinJSBridge == "undefined") {
                    if (document.addEventListener) {
                        document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                    } else if (document.attachEvent) {
                        document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                        document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                    }
                } else {
                    onBridgeReady();
                }
                /* end禁用微信分享功能 */
            });


            $(document).on('click', '#desktopShortcut', function () {
                $("#win10-shortcuts").addClass('shortcuts-hidden');
                var url = $(this).attr('data-url');
                var title = $(this).attr('data-title');
                var icon = $(this).attr('data-icon');
                Win10.openUrl(url, title, '', 'false');
            });


            //$(document).on('click', '.btnSend', function () {
            //    Y.API2("WXBase", "SendTextCardMsg", {}, function (data) {

            //        if (data.Success == false) {
            //            console.log(data.Message);
            //        } else {
            //            //var userid = data.Data.UserId;
            //            //var d = JSON.stringify(data.Data);
            //            console.log("SendMsg");
            //            console.log(data);
            //        }
            //    });
            //});


        });
    </script>
</head>
<body>
    <div id="win10">
        <div class="desktop">
            <div id="win10-shortcuts" class="shortcuts-hidden">
                <!--<div class="shortcut" onclick='Win10.openUrl("http://www.baidu.com","店铺销售明细","./img/icon/win10.png")'>
                        <img class="icon" src="./img/icon/win10.png" />
                        <div class="title">百度测试0</div>
                    </div>
                     <div id="aaa" class="shortcut btnSend">
                <img class="icon" src="./img/icon/win10.png" />
                <div class="title">测试消息</div>
                    </div> -->
            </div>
        </div>
    </div>
</body>
</html>